package com.yincheng.oes.business.franchisee.service;

import java.util.Date;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yincheng.oes.business.franchisee.entity.BCInfo;
import com.yincheng.oes.business.franchisee.entity.FranList;
import com.yincheng.oes.business.franchisee.entity.FranStudent;
import com.yincheng.oes.business.franchisee.mapper.FranStudentMapper;

@Service
public class FranStudentService {

    @Autowired
    private FranStudentMapper franStudentMapper;

    public void commitUserInfo(FranStudent bean) {
        String franId = bean.getFranId();
        String phone = bean.getPhone();
        FranStudent franStudent = franStudentMapper.selectByPhone(franId, phone);
        if (franStudent == null) {
            BCInfo bcInfo = getBCInfo();
            bean.setId(UUID.randomUUID().toString());
            bean.setCreateTime(new Date());
            bean.setMajor(bcInfo.getBcMajar());
            franStudentMapper.insert(bean);
        }
    }

    public FranList getFranInfo(String id) {
        FranList franInfo = franStudentMapper.selectById(id);
        return franInfo;
    }

    public BCInfo getBCInfo() {
        BCInfo bcInfo = franStudentMapper.selectValid();
        return bcInfo;
    }
}
